
/**
 * @brief The purpose of this class is to provide a convenient facade (interface)
 * for calculating the distance between 2 mesh objects. Basically it is
 * a wrapper for PQP C-style functions.
 *
 * @date 29.08.2011
 * @author Tomasz Rudny (rudnyt@gmail.com)
 * @version 1.0
 */

#ifndef DISTANCECOMPUTATION_H_
#define DISTANCECOMPUTATION_H_

//-----------------------------------------------------------------------------
// Include the PQP library
//-----------------------------------------------------------------------------
#include "../utils/include/PQP.h"

#include "MatVec.h"
#include <cstdio>
#include "ObjModel.h"

/*
 *
 */
namespace graph {

class DistanceComputation {
private:
	//-------------------------------------------------------------------------
	// meshes between which the distance will be computated
	//-------------------------------------------------------------------------
	PQP_Model *meshes[2];
	//-------------------------------------------------------------------------
	// The results are stored in these two variables and the value
	//-------------------------------------------------------------------------
	PQP_REAL points[2][3];
	PQP_DistanceResult dres;
	//-------------------------------------------------------------------------
	// These matrices and vectors keep the information about the
	// transformations of the meshes from their original pose
	//-------------------------------------------------------------------------
	PQP_REAL R1[3][3], R2[3][3], T1[3], T2[3];
public:
	DistanceComputation();
	virtual ~DistanceComputation();
	//-------------------------------------------------------------------------
	// loads a mesh into PQP structure from the Wave Object Loader
	//-------------------------------------------------------------------------
	void loadMesh(int i, ModelOBJ *obj);
	//-------------------------------------------------------------------------
	// set transformations
	//-------------------------------------------------------------------------
	void setRandT(PQP_REAL _R1[3][3], PQP_REAL _R2[3][3], PQP_REAL _T1[3],
			PQP_REAL _T2[3]);
	//-------------------------------------------------------------------------
	// calculate the distance and the points on the two bodies
	//-------------------------------------------------------------------------
	PQP_REAL distance();
	PQP_REAL * getPoint(int i);
};

}

#endif /* DISTANCECOMPUTATION_H_ */
